﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Esa.UI
{
    public class Inst : MonoBehaviour
    {
        public int fontSize = 24;
        public UIGrid grid;
        public BypassAudioSet source;
        public KeyCode[] keys;
        [Button]
        void SetKeys12()
        {
            keys = new KeyCode[]
            {
                KeyCode.Q,
                KeyCode.Alpha2,
                KeyCode.W,
                KeyCode.Alpha3,
                KeyCode.E,

                KeyCode.R,
                KeyCode.Alpha5,
                KeyCode.T,
                KeyCode.Alpha6,
                KeyCode.Y,
                KeyCode.Alpha7,
                KeyCode.U,

                KeyCode.I
            };
        }
        [Button]
        void SetKeys7()
        {
            keys = new KeyCode[]
            {
                KeyCode.Q,
                KeyCode.W,
                KeyCode.E,

                KeyCode.R,
                KeyCode.T,
                KeyCode.Y,
                KeyCode.U,

                KeyCode.I
            };
        }
        [Button]
        void SetKeys5()
        {
            keys = new KeyCode[]
            {
                KeyCode.Alpha2,
                KeyCode.Alpha3,

                KeyCode.Alpha5,
                KeyCode.Alpha6,
                KeyCode.Alpha7,
            };
        }
        void Start()
        {
            grid = GetComponentInChildren<UIGrid>();
            grid.onClick = OnClick;
        }

        private void OnClick(int i)
        {
            source.Play(i);
        }

        // Update is called once per frame
        void Update()
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (Events.KeyDown(keys[i]))
                {
                    source.Play(i);
                }
            }
            IMUI.fontSize = fontSize;
        }
    }
}